/**
 * Created by asus on 2017/6/10.
 */
import java.io.File;
import java.io.FileInputStream;
import java.util.LinkedList;
import java.util.List;
import java.util.Scanner;


public class Markov {


    public static void main(String[] args) throws Exception {
        Study study = new Study();
        int nwords = Integer.parseInt(args[1]);
        FileInputStream fis = new FileInputStream(new File(args[0]));
        System.out.println("Please write some worlds");
        Scanner in = new Scanner(System.in);
        String world = in.nextLine();
        List<String>list2=front(world);
        System.out.println(list2);
        study.build(fis);
        study.generate(nwords,args[2],list2);
    }
    public static List front(String S){
        List<String>list = new LinkedList<>();
        String [] s =S.split(" ");
        for (int i=2;i>0;i--){
            list.add(s[s.length-i]);
        }
        return list;
    }
}
